package sanrenxing.dayEnd.backRepertoryTotal.service.impl;


import org.springframework.stereotype.Service;
import sanrenxing.dayEnd.backRepertoryTotal.dao.LogmsgD;
import sanrenxing.dayEnd.backRepertoryTotal.domain.logMsg;
import sanrenxing.dayEnd.backRepertoryTotal.service.LogmsgBiz;

import javax.annotation.Resource;
import java.util.List;

@Service("logmsgIm")
public class LogmsgIm implements LogmsgBiz {
    @Resource
    private LogmsgD logmsgD;
    @Override
    public int add(logMsg lm) {
        return logmsgD.add(lm);
    }

    @Override
    public int del(int lm) {
        return logmsgD.del(lm);
    }

    @Override
    public int dels(String lm) {
        String [] ss=lm.split(",");
        int k=0;
        for (int i=0;i<ss.length;i++){
            k=logmsgD.del(Integer.parseInt(ss[i]));
        }
        return k;
    }

    @Override
    public List<logMsg> all(String xx, int limit, int page) {
        int h=limit*page;
        int y=(page-1)*limit;
        List<logMsg> lt=logmsgD.all(xx,h,y);
        return lt;
    }

    @Override
    public int count(String xx) {
        return logmsgD.count(xx);
    }

    @Override
    public String xx(logMsg us) {
        String xx="";
        if(us!=null){
            if(us.getUserName()!=null){
                xx+=" and userName like '%"+us.getUserName()+"%'";
            }
            if(us.getVisitTime()!=null){
                xx+=" and visitTime between to_date('"+us.getVisitTime()+" 0:0:0','yyyy-mm-dd hh24:mi:ss') and to_date('"+us.getVisitTime()+" 23:59:59','yyyy-mm-dd hh24:mi:ss')";
            }
        }
        return xx;
    }
}
